package lv.accenture.ex07;

public class TestRunner {

        public static void main(String[] args) {
                HelloRunner r = new HelloRunner();
                Thread t1 = new Thread(r, "R1");
                Thread t2 = new Thread(r, "R2");
                Thread t3 = new Thread(r, "R3");
                t1.start();
                t2.start();
                t3.start();
        }
}

class HelloRunner implements Runnable {
        private int j=0;
        public void run() {

                
                {
                while (j<150)
                {
                        System.out.println("Hello #" + j + " from "
                                        + Thread.currentThread().getName());
                        synchronized (this) {
                                j++;

                        }
                        try
                        {
                          Thread.sleep(1);
                        }
                        catch (InterruptedException e)
                        {
                                System.err.println("Interrupted");
                        }
                        
                }
                }
        }
}
